//
//  WDWorkOrderViewModel.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2024/8/2.
//

#import "WDWorkOrderViewModel.h"

@implementation WDWorkOrderViewModel

- (void)initialize {
    [super initialize];
    
    self.title = @"工单";
    
    
    _reqModel = [WDStationTaskSearchReqModel new];
    
    [self setupCurrentData];
    
    [self setupHistoryData];
}

- (void)setupCurrentData {
    // 查询时间
    _currentDates = [NSMutableArray new];
    TYZCommonCellModel *model = [TYZCommonCellModel new];
    model.title = @"最近七天";
    [self.currentDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"当月";
    [self.currentDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"三个月内";
    [self.currentDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"半年内";
    [self.currentDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"今年";
    [self.currentDates addObject:model];
    
    // 服务流程 0.待分派 1.待接车 2.检查中 3.维修中 4.待报单 5.已完成 6.已取消 7.已关闭
    _currentOrderStatus = [NSMutableArray new];
    model = [TYZCommonCellModel new];
    model.title = @"待接车";
    model.index = 1;
    [self.currentOrderStatus addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"检查中";
    model.index = 2;
    [self.currentOrderStatus addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"维修中";
    model.index = 3;
    [self.currentOrderStatus addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"待报单";
    model.index = 4;
    [self.currentOrderStatus addObject:model];
    
    // 操作人
    _currentOperators = [NSMutableArray new];
    model = [TYZCommonCellModel new];
    model.title = @"我经手的";
    [self.currentOperators addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"全部";
    [self.currentOperators addObject:model];
    
    float leftSpacee = 20;
    float midSpace = 15;
    float width = (kScreenW - leftSpacee * 2 - midSpace) * 0.5;
    float height = 38;
    NSInteger count = self.currentDates.count;
    int rows = ceilf(count / 2.0);
    float currentDatesHeight = rows * height + rows * midSpace;
    
    count = self.currentOrderStatus.count;
    rows = ceilf(count / 2.0);
    float currentOrderStatusHeight = rows * height + rows * midSpace;
    
    count = self.currentOperators.count;
    rows = ceilf(count / 2.0);
    float currentOperatorsHeight = rows * height + (rows - 1) * midSpace;
    
    
    self.currentViewHeight = 10 + 20 + 10 + currentDatesHeight + 20 + 10 + currentOrderStatusHeight + 20 + 10 + currentOperatorsHeight + 27 + 48 + 18;
    
}

- (void)setupHistoryData {
    // 查询时间
    _historyDates = [NSMutableArray new];
    TYZCommonCellModel *model = [TYZCommonCellModel new];
    model.title = @"最近七天";
    [self.historyDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"当月";
    [self.historyDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"三个月内";
    [self.historyDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"半年内";
    [self.historyDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"今年";
    [self.historyDates addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"全部";
    [self.historyDates addObject:model];
    
    // 服务流程 0.待分派 1.待接车 2.检查中 3.维修中 4.待报单 5.已完成 6.已取消 7.已关闭
    _historyOrderStatus = [NSMutableArray new];
    model = [TYZCommonCellModel new];
    model.title = @"已关闭";
    model.index = 6;
    [self.historyOrderStatus addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"已完成";
    model.index = 5;
    [self.historyOrderStatus addObject:model];
    
    // 操作人
    _historyOperators = [NSMutableArray new];
    model = [TYZCommonCellModel new];
    model.title = @"我经手的";
    [self.historyOperators addObject:model];
    
    model = [TYZCommonCellModel new];
    model.title = @"全部";
    [self.historyOperators addObject:model];
    
    
    float leftSpacee = 20;
    float midSpace = 15;
    float width = (kScreenW - leftSpacee * 2 - midSpace) * 0.5;
    float height = 38;
    NSInteger count = self.historyDates.count;
    int rows = ceilf(count / 2.0);
    float currentDatesHeight = rows * height + rows * midSpace;
    
    count = self.historyOrderStatus.count;
    rows = ceilf(count / 2.0);
    float currentOrderStatusHeight = rows * height + rows * midSpace;
    
    count = self.historyOperators.count;
    rows = ceilf(count / 2.0);
    float currentOperatorsHeight = rows * height + (rows - 1) * midSpace;
    
    
    self.historyViewHeight = 10 + 20 + 10 + currentDatesHeight + 20 + 10 + currentOrderStatusHeight + 20 + 10 + currentOperatorsHeight + 27 + 48 + 18;
}

@end































